package com.ioc.business.base.domain;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ioc.common.core.domain.BaseEntity;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 客户信息表
 * </p>
 *
 * @author WeiZhongRong
 * @since 2025-01-09
 */
@Data
@TableName("customer_info")
public class CustomerInfo extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 客户信息ID
     */
    @TableId(value = "customer_id", type = IdType.AUTO)
    private Long customerId;

    /**
     * 客户名称
     */
    private String customerName;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;


    public static Map<String, Long> toNameIdMap(List<CustomerInfo> list) {
        if (CollectionUtil.isEmpty(list)) {
            return new HashMap<>(0);
        }
        return list.stream().collect(Collectors.toMap(CustomerInfo::getCustomerName, CustomerInfo::getCustomerId));
    }
}
